{include file="public/head"/}
<script src="/static/Admin/webjs/jquery.jqprint-0.3.js"></script>
<script src="/static/Admin/webjs/jquery-migrate.min.js"></script>
<script language="javascript">
	$(document).ready(function () {
		// datatimepicker 设置
		$('.form_datetime').datetimepicker({
			language: 'zh-CN', // en ,zh-CN, pt-BR
			minView: 'month',
			weekStart: 0, //一周从哪一天开始
			todayBtn:  1, //
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			forceParse: 0,
			showMeridian: 1
		});
	});
</script>
<div class="container-fluid" id="main">
<!--search框开始-->
<div class="row clearfix" id="search-box" style="display:none;margin-top:0">
    <div class="col-md-12 text-right">
        <div>
            <form class="form-inline" role="form">

                <div class="form-group">
                    <label for="name">{:strtoupper(lang('search_content'))}</label>
                    <input type="text" class="form-control" id="name" placeholder="{:strtoupper(lang("please_enter_a_company_name"))}" v-model="cond.searchText">
                </div>
                <div class="form-group">
                    <button type="button" class="btn btn-default btn-primary" @click="getdata"><span class="glyphicon glyphicon-search"></span>{:strtoupper(lang('search'))}</button>
                </div>
            </form>
		</div>
	</div>
</div>

<!--search框结束-->
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="alert alert-dismissable alert-info">
                <button type="button" class="close">×</button>
                <p></p>
            </div>
        </div>
    </div>
   
   
    <div class="ntDesktop">
    	<div class="ntDesktop-head">{:strtoupper(lang("list_of_purchase_contracts"))}</div>
    
        <div class="row clearfix" style="padding-top:0px">
            <div class="col-md-4">
                <div class="btn-group">

                    <button type="button" class="btn btn-default btn-checkbox" v-if="isshow_search">
                        搜索结果
                        <span class="glyphicon glyphicon-remove shdow" style="margin-left: 10px;" @click="shdow()"></span>
                    </button>

                    <button type="button" class="btn btn-default btn-checkbox" @click="changestatus('all')">
                        <input type="checkbox"  v-if="isshow_search"> 
                        <input type="checkbox" checked v-else> 
                        {:strtoupper(lang('all'))}
                    </button>
                    <button type="button" class="btn btn-default btn-checkbox" @click="changestatus('sign')">
                        <input type="checkbox">{:strtoupper(lang("signed"))}
                    </button>
                    <button type="button" class="btn btn-default btn-checkbox" @click="changestatus('play')">
                        <input type="checkbox">{:strtoupper(lang("paid"))}
                    </button>
                    <button type="button" class="btn btn-default btn-checkbox" @click="changestatus('receipt')">
                        <input type="checkbox">{:strtoupper(lang("received"))}
                    </button>
                </div>
                <button type="button" class="btn btn-default btn-checkbox" @click="changestatus('del')">
                    <input type="checkbox">{:strtoupper(lang("deleted"))}
                </button>
            </div>
            <div class="col-md-4">
            	<div class="btn-group">
	            	<button type="button" class="btn btn-default btn-checkbox" @click="changestatus('iscontent')">
                        <input type="checkbox"> {:strtoupper(lang("expand_display_contract_content"))}</button>
                	<button type="button" class="btn btn-default btn-checkbox" @click="changestatus('iszwxd')">
                        <input type="checkbox"> {:strtoupper(lang("expand_the_packing_list"))}</button>
                </div>
            </div>
            <div class="col-md-4 text-right">
                <div>
                    <a href="javascript:;" class='btn btn-primary' @click="batch('batchSign')" v-if="auth_ids.indexOf(285) != -1">
                        <span class="fa fa-award"></span> {:strtoupper(lang("batch_signing"))}</a>
                    <a href="javascript:;" class='btn btn-primary' @click="batch('batchReceipt')" v-if="auth_ids.indexOf(286) != -1">
                        <span class="fa fa-truck"></span> {:strtoupper(lang("receipt_in_tabches"))}</a>
                    <button class='btn btn-default' @click="batch('batchDel')" v-if="auth_ids.indexOf(287) != -1">
                        <span class="glyphicon glyphicon-trash"></span> {:strtoupper(lang('batch_delete'))}</button>
                </div>
            </div>
        </div>
        <!--startprint-->
        <div class="row clearfix" id="printArea">
            <div class="col-md-12 column">
                <table class="table table-striped table-hover ntTable" v-cloak>
                    <thead>
                        <tr>
                            <th style="text-align:center"><input type="checkbox" v-model="allche" @change="changeall" /> </th>
                            <th class="sorting" @click="storing(0,'id')"> No. </th>
                            <th class="sorting" @click="storing(0,'delivery_day')">{:strtoupper(lang("delivery_time/address"))}  </th>
                            <th> {:strtoupper(lang("supplier"))}</th>
                            <th> {:strtoupper(lang("box_quantity"))} </th>
                            <th> {:strtoupper(lang("volume"))}/{:strtoupper(lang("weight"))} </th>
                            <th class="sorting"> {:strtoupper(lang('amount'))}/{:strtoupper(lang('paid'))} </th>
                            <th> {:strtoupper(lang("signed"))} </th>
                            <th> {:strtoupper(lang("received"))} </th>
                            <th class="sorting"> {:strtoupper(lang('edit'))} </th>
                            <th class="text-center"> {:strtoupper(lang('operate'))} </th>
                        </tr>
                    </thead>
                    <tbody>
                        <template  v-for="(item,index) in data">
                            <tr>
                                <td style="vertical-align:middle" class="text-center"><input type="checkbox"  value="item.id" v-model="cheval[index].val" /></td>
                                <td style="vertical-align:middle">{{formatUnit(item.id,'ID')}}</td>
                                <td>
                                    <small>{{item.delivery_day}}</small><br>
                                    {{item.port_name}}
                                </td>
                                <td style="vertical-align:middle"><a :href="'/admin/customer/companycheck?company_id='+item.company_id+'&tab=detail'">{{item.company_name}}</a></td>
                                <td   align="right"> {{formatUnit(item.qty_sum,'UN')}} <span class="unit">CTN</span> </td>
                                <td  align="right">
                                    {{formatUnit(item.m3_sum,'M3')}} <span class="unit">CBM</span><br>
                                    {{formatUnit(item.kgs_sum,'KG')}} <span class="unit">KGS</span>
                                </td>
                                <td  align="right">
                                    {{formatUnit(item.cost_sum+item.price_sum,'$')}} <span class="unit">CNY</span><br>
                                    {{formatUnit(item.paid,'$')}} <span class="unit">CNY</span>
                                </td>
                                <td style="text-align:center;">{{item.sign}}</td>
                                <td style="text-align:center;">{{item.receipt}}</td>
                                <td style="text-align:center;"> {{item.create_name}} <br /><small>{{item.create_time}} </small></td>
                                <td style="vertical-align:middle" class="text-right">
                                    <div>
                                        <a :href="'/admin/buypo/checkView?request=view&&id='+item.id" class='btn btn-sm btn-primary' v-if="auth_ids.indexOf(288) != -1" @click="setStorage()">
                                            <span class="fa fa-search-plus"></span> {:strtoupper(lang('view'))}</a>

                                        <a :href="'/admin/buypo/editBuyPo?request=edit&id='+item.id" class='btn btn-sm btn-primary' v-if="(auth_ids.indexOf(367) != -1 && item.sign != 'O') || auth_ids.indexOf(396) != -1" @click="setStorage()">
                                            <span class="glyphicon glyphicon-pencil"></span> {:strtoupper(lang('edit'))}</a>

                                        <a :href="'/admin/buypo/print?request=view&id='+item.id" class='btn btn-sm btn-primary' v-if="auth_ids.indexOf(289) != -1" @click="setStorage()">
                                            <span class="fa fa-print"></span> {:strtoupper(lang("print"))}</a>
                                            
                                        <a href="po_copy.html" class='btn btn-sm btn-primary' v-if="auth_ids.indexOf(367) != -1">
                                            <span class="fa fa-copy"></span> {:strtoupper(lang('copy'))}</a>

                                        <div class="btn-sm btn-group">
                                            <button type="button" class="btn btn-sm btn-primary dropdown-toggle" data-toggle="dropdown">
                                                {:strtoupper(lang('more_actions'))}<span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu text-left">
                                                <li v-if="item.sign=='O'">
                                                    <a href="#"><span class="fa fa-comment-dollar"></span>{:strtoupper(lang('payment'))}</a></li>
                                                <li @click="oneaction('batchSign',item.id)" v-show="item.sign!='O' && auth_ids.indexOf(285) != -1">
                                                    <a href="#"><span class="fa fa-award"></span> {:strtoupper(lang("confirm_the_contract"))}</a></li>
                                                <template v-if="item.is_container == 2">
                                                    <li @click="oneaction('batchCancelSign',item.id)" v-show="item.sign=='O' || item.is_container == 0" v-if="auth_ids.indexOf(290) != -1">
                                                        <a href="#"><span class="fa fa-award"></span> 取消签约</a></li>
                                                    <li @click="oneaction('batchReceipt',item.id)" v-show="item.sign=='O' && item.receipt!='O' && auth_ids.indexOf(291) != -1">
                                                        <a href="#"><span class="fa fa-truck"></span> {:strtoupper(lang("confirm_receipt_merchandise"))}</a></li>
                                                    <li @click="oneaction('batchIsReceipt',item.id)" v-show="item.receipt=='O' || item.is_container == 0"  v-if="auth_ids.indexOf(290) != -1">
                                                        <a href="#"><span class="fa fa-truck"></span> 取消收货</a></li>
                                                    <li @click="oneaction('batchDel',item.id)" v-show="item.sign!='O' && auth_ids.indexOf(287) != -1">
                                                        <a href="#"><span class="glyphicon glyphicon-trash"></span> {:strtoupper(lang('delete'))}</a></li>
                                                </template>
                                            </ul>

                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <tr v-if="iscontent==1">
                                    <td colspan="2">&nbsp;</td>
                                    <td colspan="9">
                                        <table class="table table-striped">
                                            <thead>
                                            <tr>
                                                <th>No.</th>
                                                <th>&nbsp;</th>
                                                <th>{:strtoupper(lang('product'))}</th>
                                                <th>{:strtoupper(lang("quantity"))}</th>
                                                <th>{:strtoupper(lang("box_measure"))}</th>
                                                <th>{:strtoupper(lang("volume"))}/{:strtoupper(lang("weight"))}</th>
                                                <th>{:strtoupper(lang('amount'))}</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr v-for="(row,index) in item.buy_plan">
                                                <td style="vertical-align:middle" align="center">{{row.id}}</td>
                                                <td style="vertical-align:middle" align="center"><img :src="row.img_url" border="0"></td>
                                                <td><a :href="'/admin/product/productDetail?request=detail&id='+row.pro_id">
                                                    <small>
                                                        {{
                                                        (row.prochar_id ? row.prochar_id : row.pro_id )
                                                        +
                                                        (row.brand_name ? ' / '+row.brand_name : '')
                                                        +
                                                        (row.model ? ' / '+row.model : '')
                                                        }}
                                                    </small> <br />
                                                    {{row.pro_name}} </a> </td>
                                                <td align="right">
                                                    {{formatUnit(row.qty,'UN')}} <span class="unit">CTN</span><br /> {{formatUnit(row.qty_sum,'UN')}} <span class="unit">PCS</span>
                                                </td>
                                                <td align="right">
                                                    {{formatUnit(row.ctn_qty,'UN')}} <span class="unit">PCS/CTN</span> | {{formatUnit(row.ctn_kgs,'KG')}} <span class="unit">KGS/CTN</span><br>
                                                    {{formatUnit(row.ctn_size,'M')}} <span class="unit">CM</span> | <!-- {{row.ctn_m3>1 ? Money(row.ctn_m3,2) : Money(row.ctn_m3,3)}} -->{{formatUnit(row.ctn_m3,'M3')}} <span class="unit">CBM/CTN</span>
                                                </td>
                                                <td align="right">
                                                    <!-- {{row.m3_sum > 1 ? Money(row.m3_sum,2) : Money(row.m3_sum,3)}} --> {{formatUnit(row.m3_sum,'M3')}}<span class="unit">CBM</span><br>
                                                    {{formatUnit(row.kgs_sum,'KG')}} <span class="unit">KGS</span>
                                                </td>
                                                <td align="right">
                                                    {{formatUnit(row.price,'$')}} <span class="unit">CNY</span><br>
                                                    {{formatUnit(row.price_sum,'$')}} <span class="unit">CNY</span>
                                                </td>
                                            </tr>
                                            </tbody>
                                            <tfoot>
                                            <tr>
                                                <td colspan="2" align="center">{:strtoupper(lang('total'))}</td>
                                                <td colspan="5" align="right">
                                                    <b>
                                                        {:strtoupper(lang('product'))}： {{formatUnit(item.plan_sum,'UN')}} <span class="unit">UN</span> /
                                                        {:strtoupper(lang("box_quantity"))}： {{formatUnit(item.qty_sum,'UN')}} <span class="unit">CTN</span> /
                                                        {:strtoupper(lang("volume"))}： <!-- {{item.m3_sum>1 ? Money(item.m3_sum,2) : Money(item.m3_sum,3)}} -->{{formatUnit(item.m3_sum,'M3')}}<span class="unit">CBM</span> /
                                                        {:strtoupper(lang("weight"))}： {{formatUnit(item.kgs_sum,'KG')}} <span class="unit">KGS</span> /
                                                        {:strtoupper(lang('amount'))}： {{formatUnit(item.price_sum,'$')}} <span class="unit">CNY</span>
                                                    </b>
                                                </td>
                                            </tr>
                                            </tfoot>
                                        </table>
                                    </td>
                                </tr>
                            <tr v-if="iszwxd==1">
                                <td colspan="2">&nbsp;</td>
                                <td colspan="9">
                                    <table class="table table-striped">
                                        <thead>
                                            <tr>
                                                <th>No.</th>
                                                <th>&nbsp;</th>
                                                <th>{:strtoupper(lang('product'))}</th>
                                                <th>{:strtoupper(lang("quantity"))}</th>
                                                <th>{:strtoupper(lang("box_measure"))}</th>
                                                <th>{:strtoupper(lang("volume"))}/{:strtoupper(lang("weight"))}</th>
                                                <th>{:strtoupper(lang("container"))}</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr v-for="(row,index) in item.buy_po_pack">
                                                    <td style="vertical-align:middle" align="center">{{row.id}}</td>
                                                    <td style="vertical-align:middle" align="center"><img :src="row.img_url" border="0" width="48px"></td>
                                                    <td>
                                                        <template v-if="row.pro_name">
                                                            <a :href="'/admin/product/productDetail?request=detail&id='+row.pro_id">
                                                                <small>
                                                                        {{
                                                                        (row.prochar_id ? row.prochar_id : row.pro_id )
                                                                        +
                                                                        (row.brand_name ? ' / '+row.brand_name : '')
                                                                        +
                                                                        (row.model ? ' / '+row.model : '')
                                                                        }}
                                                                </small> <br />
                                                                {{row.pro_name}}
                                                            </a>
                                                            <br>
                                                        </template>
                                                        <span :style="{'line-height': row.pro_name ? '': '60px'}">{{row.note}}</span>
                                                    </td>
                                                    <td  align="right"> {{formatUnit(row.qty,'UN')}} <span class="unit">CTN</span><br /> {{formatUnit(row.qty_sum,'UN')}} <span class="unit">PCS</span></td>
                                                    <td align="right">
                                                            {{formatUnit(row.ctn_qty,'UN')}} <span class="unit">PCS/CTN</span> | {{formatUnit(row.ctn_kgs,'KG')}} <span class="unit">KGS/CTN</span><br>
                                                            {{formatUnit(row.ctn_size,'M')}} <span class="unit">CM</span> | <!-- {{row.ctn_m3>1 ? Money(row.ctn_m3,2) : Money(row.ctn_m3,3)}} -->{{formatUnit(row.ctn_m3,'M3')}} <span class="unit">CBM/CTN</span>
                                                    </td>
                                                    <td  align="right">
                                                        <!-- {{row.m3_sum>1 ? Money(row.m3_sum,2) : Money(row.m3_sum,3)}} -->{{formatUnit(row.m3_sum,'M3')}} <span class="unit">CBM</span><br>
                                                        {{formatUnit(row.kgs_sum,'KG')}} <span class="unit">KGS</span>
                                                    </td>
                                                    <td  align="right">
                                                        {{row.name ? row.name : '-'}}<br>
                                                        {{row.container_time}}.{{row.container_status}}
                                                    </td>
                                                </tr>
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <td colspan="2" align="center">{:strtoupper(lang('total'))}</td>
                                                <td colspan="5" align="right">
                                                    <b>
                                                    {:strtoupper(lang('product'))}： {{formatUnit(item.plan_sum,'UN')}} <span class="unit">UN</span> /
                                                    {:strtoupper(lang("box_quantity"))}： {{formatUnit(item.qty_sum,'UN')}} <span class="unit">CTN</span> /
                                                    {:strtoupper(lang("volume"))}： <!-- {{item.m3_sum>1 ? Money(item.m3_sum,2) : Money(item.m3_sum,3)}} -->{{formatUnit(item.m3_sum,'M3')}} <span class="unit">CBM</span> /
                                                    {:strtoupper(lang("weight"))}： {{formatUnit(item.kgs_sum,'KG')}} <span class="unit">KGS</span> /
                                                    </b>
                                                </td>
                                            </tr>
                                        </tfoot>
                                    </table>
                                </td>
                            </tr>
                        </template>
                        <tr><td colspan="11" style="text-align: center;" v-if="data.length==0" class="no_date">{:strtoupper(lang('no_data'))}</td></tr>
                    </tbody>
                </table>
                <ul class="pagination" id="pagination">
                </ul>
            </div>
        </div>
        <!--endprint-->
    </div>
</div>

<script src="/static/Admin/js/buypo.js"></script>
{include file="public/foot"/}